package ar.uba.fi.tp2Unit.displayers.xml;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class TestCaseXML implements XMLSerializable {
	
	private String name;
	private String time;
	private ErrorXML error;
	private FailureXML failure;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getTime() {
		return time;
	}
	public void setTime(String time) {
		this.time = time;
	}
	public ErrorXML getError() {
		return error;
	}
	public void setError(ErrorXML error) {
		this.error = error;
	}
	public FailureXML getFailure() {
		return failure;
	}
	public void setFailure(FailureXML failure) {
		this.failure = failure;
	}
	
	public Node serializeXml(Document doc) {
		Element element = doc.createElement("testcase");
		element.setAttribute("name", this.getName());
    	element.setAttribute("time", this.getTime());
    	if (this.failure != null) {
    		element.appendChild(this.failure.serializeXml(doc));
    	}
    	if (this.error != null) {
    		element.appendChild(this.error.serializeXml(doc));
    	}
    	return element;
	}
}
